var util = {
    getdicbycode: function (search, cb) {
        $.post(apiurl + "/quanxian/getdicbycode", search, function (data) {
            cb(data);
        });
    },
    getgoodlist: function (search, cb) {
        $.post(apiurl + "/quanxian/chuzhi/list", search, function (data) {
            cb(data);

        });
    },
    getpersoninfo: function (search, cb) {

        $.post(apiurl + "/api/person/view", search, function (data) {
            cb(data);

        });
    },
    getvipinfo: function (search, cb) {
        $.post(apiurl + "/person/personopencard/vipinfo", search, function (data) {
            cb(data);
        });
    },
    GetRequest: function (value) {
        var url = decodeURI(location.search); //?id="123456"&Name="bicycle";
        var object = {};
        if (url.indexOf("?") != -1) {
            //url中存在问号，也就说有参数。
            var str = url.substr(1); //得到?后面的字符串
            var strs = str.split("&"); //将得到的参数分隔成数组[id="123456",Name="bicycle"];
            for (var i = 0; i < strs.length; i++) {
                object[strs[i].split("=")[0]] = strs[i].split("=")[1];
            }
        }
        return object[value];
    },
    compare: function (prop) {
        return function (obj2, obj1) {
            var val1 = obj1[prop];
            var val2 = obj2[prop];
            if (!isNaN(Number(val1)) && !isNaN(Number(val2))) {
                val1 = Number(val1);
                val2 = Number(val2);
            }
            if (val1 < val2) {
                return -1;
            } else if (val1 > val2) {
                return 1;
            } else {
                return 0;
            }
        }
    }
}

